function triTexture = getTexture(origin, A, B, img)

U = A - origin;
V = B - origin;
C = origin+U+V;  %# Point C


[nRows,nCols,nPages] = size(img);  %# Image dimensions
inputCorners = [origin; ...        %# Corner coordinates of input space
                A; ...
                C; ...
                B];
outputCorners = [1 nRows; ...      %# Corner coordinates of output space
                 nCols nRows; ...
                 nCols 1; ...
                 1 1];
tform = maketform('projective',...  %# Make the transformation structure
                  inputCorners,...
                  outputCorners);
triTexture = imtransform(img,tform,'bicubic',...  %# Transform the image
                         'xdata',[1 nCols],...
                         'ydata',[1 nRows],...
                         'size',[100 100]);

            
    